package com.itheima.d6_threadhomework0910.num5;

public class PrintCharTask implements Runnable {
    /*
          2.创建PrintCharTask作为线程任务类实现Runnable接口
         *        用于打印字母A-Z
         *         要求升序
         */
    @Override
    public void run() {
        char ch = 'A';
        while (true) {
            if (ch > 'Z') {
                break;
            }
            //线程上锁
            synchronized (this) {
                System.out.print(ch + " ");
                ch++;
            }
        }



        //沉睡一下
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
